"use strict";
$(function(){
    showBoxView();

    var timer = setInterval(function(){
        showBoxView();
    },1000);


    $(".title-icon-group a").click(function(){
        $(".title-icon-group a").removeClass("active");
        $(this).addClass("active");
        var id = $(this).attr("id");
        if(id=="detail"){
            $("div[name=engine-system-info-box]").show();
            $(".engine-content").css("min-height","172px")
        }else if(id=="simple"){
            $("div[name=engine-system-info-box]").hide();
            $(".engine-content").css("min-height","0px")
        }

    });
    $("#detail").trigger("click");

});

function showBoxView(){
    Ajax({
        url:contextPath+"/console/magent/getHostInfo",
        data:{},
        success:function (data) {
            var html = template('hostTemplate',data);
            $(".main-engine-box").html(html);

            $("span[name=hostStatus]").hover(function(){
                if($(this).attr("tips")!=""){
                    apexLayer.Tips({guide:1,object:$(this),message:$(this).attr("tips"),time:0});
                }
            },function(){
                apexLayer.CloseAll();
            });

            $("span[name=nodeStatus]").hover(function(){
                if($(this).attr("tips")!=""){
                   apexLayer.Tips({guide:1,object:$(this),message:$(this).attr("tips"),time:0});
                    $(".layui-layer-tips .layui-layer-content").css("margin-left","-10px");
                    $(".layui-layer-tips i.layui-layer-TipsT").css("left","1px");
                }
            },function(){
                apexLayer.CloseAll();
            });

        },
        error:function (e) {

        }
    });
}